package com.dylan.历史.eventbus;

import com.dylan.历史.util.SleepUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Date;

/**
 * @author : ankang
 * @date : 2020/12/12 14:23
 * @Description :
 */
public class MyEvent {
    private static String format = "HH:mm:ss.SSS";
    private int index;
    private Date sendTime;

    public MyEvent(int index, Date sendTime) {
        this.index = index;
        this.sendTime = sendTime;
    }

    public void handle(String flag) {
//        System.out.println(flag + index +" 发送时间:" + DateFormatUtils.format(sendTime, format));
        System.out.println(flag + index +" 开始执行时间:" + DateFormatUtils.format(new Date(), format));
        SleepUtils.milliseconds(RandomUtils.nextInt(100, 1000));
        System.out.println(flag + index +" 结束执行时间:" + DateFormatUtils.format(new Date(), format));
    }
}
